const mongoose = require('mongoose')
const Schema = mongoose.Schema
mongoose.connect('mongodb://localhost/news')
const moment=require('moment')
moment.locale('zh-cn') //设置时区

const CommentSchema = new Schema({
  username: {
    type: String
  },
  content: {
    type: String
  },
  nid: {
    type: String
  },
  uid:{
    type:String
  },
  title: {
    type: String
  },
  topic: {
    type: String
  },
  date: {
    type: String,
    default: () => {
      return moment().format('YYYY-MM-DD HH:mm:ss')
    }
  }
})

const Comment = mongoose.model('comment', CommentSchema)
module.exports = Comment